class AskTopicAboutWater : ShuffledEventList
  [
    '<q>Ah, water... If only we had more of it...</q>',
    '<q>I feel thirsty, as much as everybody, but duty first, as they say!</q>',
    '<q>The water tastes like camel piss if you ask me, but it is still the most precious of our belongings.</q>',
    '<q>We are lucky to have found water, even if it so deep and has such a foul taste.</q>',
    '<q>That well pump may be noisy, but it is the heart that brings life to the fort.</q>'
  ]
;

mission : Topic 'mission/work/duty/doing/occupation';

fortFloor : Floor 'fort floor/ground/soil' 'fort ground'
  "The ground is made of trampled sand and gravel."
;

fortWall : DefaultWall 'fort walls' 'fort walls'
  "The wall is made of rusty pieces of steel bolted together and supported
  by various metal poles and rails shoved in the ground."
;

tankDormitory : Room 'Dormitory'
  "You are in an old rusty container that has been reconverted into a dormitory.
  The air is thick with the smell of sweaty unwashed bodies and with human heat.
  Several half-naked peoples of both sexes are sleeping on the ground or in hammocks.
  The sparse light comes from a hole pierced through the wall and covered
  by a leather curtain, a kind of door that leads out to the camp yard.
  <<well.isWorking ? 'A regular thumping sound is coming from outside'
    : ''>>.  "
  smellDesc = "An acrid smell of cold sweat and dried sperm is floating around. "

  out = fortYard

  atmosphereList : ShuffledEventList
  {
    [
      'The sun beating on the tank makes the air hot and difficult to breathe.\n',
      'The air is thick with the sweat smell accumulated inside this badly ventiled room.\n',
      'A strong smell of rancid sperm and sex is making you wrinkle your nose.\n',
      'You are sweating in the barely bearable heat.\n'
    ]
    eventPercent = 90
    eventReduceAfter = 4
    eventReduceTo = 50
  }
;

// ********************** Yard ********************
fortYard : OutdoorRoom 'In front of the container dormitory'
  "An area of desert soil cirucmwalled by rusty steel scraps forming a defensive circle.
  The large container that serves as a dormitory occupies the centre of the fort. A leather curtain covers
  the way in. To the north is the well with its noisy pumping machine.
  To the south lies a large gate, currently closed.
  A wooden wall isolates the eastern part of the yard.
  A ladder leads to a walkway going all along the top of the walls.
  The western half of the area is occupied by a plantation of some kind of vegetables.
  <<well.isWorking ? '<.p>A regular, loud thump thump thump is coming from the well pumping device'
    : ''>>. "

  in = tankDormitory
  up = fortWalkway
  south = fortFrontOfGate
  west = fortPlantations
  east = fortRestrooms
  north = fortWell

  roomParts = [fortFloor, fortWall]
  isPrivate = nil

  roomDaemon ( )
  {
    if(!well.isBreaking)
    {
      new Fuse(well, &fuse, 10);
      well.isBreaking = true;
    }
  }
;

+ Distant 'pumping well/pump/machine' 'pump'
  "The well lies to the north of the fort yard. "
;

// ************** Well ********************
fortWell: OutdoorRoom 'By the well'
  "You are by the fort well, close to the fort northern wall.
  To the south, the dormitory container lies in the middle of the yard.
  <<well.isWorking ? '<.p>The thump thump thump of the well pumping device is particularly loud here'
    : ''>>. "

  south = fortYard

  roomParts = [fortWall]
  isPrivate = nil
;

+ well : Fixture, Topic 'mechanical (fort) pumping well/machinery/device/water/pipes/pump' 'mechanical well'
  "The well consists of a piece of massonry capped by a bulky machinery designed
  to pump the water from the desert depths and to pipe it into an underground storage tank.
  Several padlocked taps allows one to get the water from the tank. One pipe goes west to the plantations.
  <<isWorking ? 'A regular, loud thump thump thump is coming from the pumping device'
    : 'The pumping machinery is strangely silent. Its main hood is lifted, exposing the complexity of its entrails'>>. "

  isBreaking = nil
  isWorking = true
  isKnown = true

  fuse
  {
    "There is a sudden change in the well pump thumping. It gets irregular, less loud
    and finally it stops altogether.";
    isWorking = nil;
    engineer.curState = engineerWellBrokenBusy;
  }
;

engineer : Person 'well pump engineer/Jeff' 'engineer'
  @fortWell
  "This is a rather skinny, old, bald, guy with a short beard.
  He is clad in a dirty tunic whose material is smeared with uncountable
  oily stains.
  <<well.isWorking ? 'He is busy lubricating the pump engine with a small bottle of oil.
    He looks at you over his shoulder, smiles, and turns back to his work'
    : 'He is scratching his greasy hair with his left hand, looking at the pumping machinery whose main
      hood is lifted, exposing the complexity of its entrails'>>. "
  properName = 'Jeff'
  globalParamName = 'engineer'
  isHim = true
;

+ DefaultAskTellTopic, ShuffledEventList
  [
    'The engineer scratches his head, <q>Well, Kriss. That\'s difficult to explain.</q>',
    '<q>Mmmmh, well...</q> he grumbles. ',
    'The engineer does not answer, looking at his machine with concern. ',
    'He rubs his beard, <q>I\'m not sure how to say it...</q>'
  ]
;

+ engineerWellWorkingTalking : InConversationState
  stateDesc = "He's standing talking with you. "
  specialDesc = "He is stomping the ground nervously. "
;

++ engineerWellWorkingBusy : ConversationReadyState
  stateDesc = "He is lubricating the pump engine with a small bottle of oil. "
  specialDesc = "The pump engineer is walking round the engine, occasionally oiling some valve or
    tightening some bolt. "
  isInitState = true
;

+++ HelloTopic, StopEventList
  [
    '<q>Er, excuse me Jeff,</q> you say, trying to get the engineer\'s attention.<.p>
     He turns his head angrily but as her recognizes you, a wide smile shines on his face.
     <q>Hello, Kriss. Hot day isn\'it?.</q>',
    '<q>Hello Jeff!</q> you call.<.p>
     <q>Hello again!</q> the engineer declares, pausing from his labours to lean against his engine. '
  ]
;

+++ ByeTopic
  "<q>Bye for now, then.</q> you say.<.p>
   <q>Bye Kriss!</q> he answers as he returns to his work. "
;

+++ ImpByeTopic
  "The engineer gives a little shake of the head and returns to his work. "
;

++ AskTopic @well
  "<q>Well, Jeff, I've always wondered... How can this pump gets water from the dry desert?</q> you ask.<.p>
   <q>I'm glad you are asking</q> he answers. <q>We found an abandoned well many years ago.
   There was very little water in it, but by drilling much deeper, we reached a new, untapped
   reservoir. It was so deep though that we had to mount this pumping machinery to get the water
   to the surface.<.p>
   We pump the water into an underground tank, and from there we distribute it, either to
   drink it or for the plantations. Water is so precious that we have to restrict its use severely
   and to make sure nobody get it out of her or his turn.<.p>
   I hope this has answered your question, Kriss.</q>"
;

+ engineerWellBrokenTalking : InConversationState
  stateDesc = "He's standing talking with you. "
  specialDesc = "He is leaning against the well. "
;

++ engineerWellBrokenBusy : ConversationReadyState
  stateDesc = "He is scratching is head nervously. "
  specialDesc = "The pump engineer is walking nervously round the well, scratching
    and tearing his hair. "
;

+++ HelloTopic, StopEventList
  [
    '<q>Hey Jeff, what\'s going on with the well?</q> you ask, worried by the engineer\'s nervosity.<.p>
     <q>Ah, don\'s tell me about it. It\'s a nightmare!</q>',
    '<q>Hey Jeff! Any luck with the pump yet?</q> you call.<.p>
     <q>Nothing! And I\'m affraid there is nothing to be hoped until I get a new power cell...</q> he answers in a sad voice. '
  ]
;

+++ ByeTopic
  "<q>Bye for now, then.</q> you say.<.p>
   <q>See you Kriss!</q> he answers as he returns to his work. "
;

+++ ImpByeTopic
  "The engineer gives a little shake of the head and returns to his work. "
;

++ DefaultAskTellTopic
  "<q>Alas!</q> he laments. <q> The power cell has died! There is no way to make the pump
  work again. This is terrible!</q>"
;

// ****************** Walkway *****************
fortWalkway : OutdoorRoom 'Walkway'
  "The walkway goes all around the wall of the camp.
  A dry, hot desert goes to the horizon in all directions.
  <<well.isWorking ? 'A regular, loud thump thump thump is coming from the well pumping device'
    : ''>>. "

  down = fortYard

  isPrivate = nil
;

+ Distant 'pumping well/pump/machine' 'pump'
  "The well lies to the north of the fort yard. "
;

// ************** Plantation ***********
fortPlantations : OutdoorRoom 'Plantations'
  "This half of the fort is occupied by rows of rachitic vegetables. Several pierced rusty steel pipes are running along the rows,
  periodically bringing precious water to the thirsty plants. A guard is patrolling the fields
  and a dozen of workers of both sexes are tending the meagre vegetables.
  <<well.isWorking ? 'A regular, loud thump thump thump is coming from the well pumping device'
    : ''>>. "

  east = fortYard

  roomParts = [fortWall]
  isPrivate = nil
;

+ Distant 'pumping well/pump/machine' 'pump'
  "The well lies to the north of the fort yard. "
;

+plantation : Fixture 'plantations/vegetables/food/plants' 'plantation'
  "Row after row after row of rachitic, pale leaves. The edible part is a hard-to-chew root underground."
;

plantationGuard : Person 'plantation guard/Joe' 'guard'
  @fortPlantations
  "He is wearing a leather outfit, quite similar to yours, and is armed with a makeshift sword. "
  properName = 'Joe'
  globalParamName = 'plantation guard'
  isHim = true
;

+ DefaultAnyTopic, ShuffledEventList
  [
    'The guard shakes his head, <q>Sorry, Kriss. I\'m on duty, can\'t chat now.</q>',
    '<q>Shhhht! I\'m on duty.</q> he whispers. ',
    'He remains mute, scanning the plantations with his sharp eyes. '
  ]
;

+ HelloTopic, StopEventList
  [
    '<q>Hi Joe!</q> you say to the guard.<.p>
     He gives you a short, respectful glance and seethes through his teeth
     <q>Hi Kriss!</q>',
    '<q>Hi again, Kriss! I\'m on duty now. Let\'s talk later.</q> he answers your greeting. '
  ]
;

+ AskTopic @mission
  "<q>Joe, what\'s your mission today?</q> you ask<.p>
  <q>I\'m ensuring nobody steals food or drinks water, Kriss</q> he answers in a professional tone."
;

+ AskTopic, AskTopicAboutWater @well;

plantationWorker : Person 'plantation worker/Suzi' 'worker'
  @fortPlantations
  "She is wearing a dirty, skimpy tunic, which leaves most of her legs, arms and cleavage naked.
  She is kneeling on the ground, shovelling earth around the vegetables. "
  properName = 'Suzi'
  globalParamName = 'plantation worker'
  isHer = true
;

+ DefaultAnyTopic, ShuffledEventList
  [
    'The worker grumbles something impossible to understand.',
    '<q>Mmmh... Yes... Indeed</q> she says. ',
    'She remains mute, working hard, sweating in the hot sun. '
  ]
;

+ HelloTopic, StopEventList
  [
    '<q>Hi there!</q> you say to the kneeling girl.<.p>
     She lifts her head and gives you a tired smile. Her face is glistening with sweat.
     <q>Hi Kriss!</q>',
    '<q>Hi again!</q>'
  ]
;

+ AskTopic @mission
  "<q>What are you doing here?</q> you ask<.p>
  <q>I\'m making sure nothing is preventing the roots to get as much water as they can, Kriss.
  There is so little of it that we don\'t want to lose the least drop.</q> she answers."
;

+ AskTopic, AskTopicAboutWater @well;

// ****************** Gate *********************
fortFrontOfGate : OutdoorRoom 'In front of the gate'
  "You stand at the foot of a large gate going through the fort walls.
  A guard is standing in front of it.
  <<well.isWorking ? 'A regular, loud thump thump thump is coming from the well pumping device'
    : ''>>. "

  north = fortYard
  out = fortGate

  roomParts = [fortWall]
  isPrivate = nil
;

+ Distant 'pumping well/pump/machine' 'pump'
  "The well lies to the north of the fort yard. "
;

+ fortGate : Lockable, Door 'fort gate/doors' 'gate'
  "It's a high, wide archway made of two pivoting slates of rusty iron.
  The doors are padlocked. "
  isLocked = true
;

gateGuard : Person 'plantation guard/Bill' 'guard'
  @fortFrontOfGate
  "He is wearing a leather outfit, quite similar to yours, and is armed with a makeshift sword. "
  properName = 'Bill'
  globalParamName = 'gate guard'
  isHim = true
;

+ DefaultAnyTopic, ShuffledEventList
  [
    'The guard shakes his head, <q>Sorry, Kriss. I\'m on duty, can\'t chat now.</q>',
    '<q>Shhhht! I\'m on duty.</q> he whispers. ',
    'He remains mute, as if looking above your head. '
  ]
;

+ HelloTopic, StopEventList
  [
    '<q>Hi Bill!</q> you say to the guard.<.p>
     He gives you a short, respectful glance and seethes through his teeth
     <q>Hi Kriss!</q>',
    '<q>Hi again, Kriss! I\'m on duty now. Let\'s talk later.</q> he answers your greeting. '
  ]
;

+ AskTopic @mission
  "<q>Bill, what\'s your mission today?</q> you ask<.p>
  <q>I\'m ensuring nobody enters or exits through these gates, Kriss.</q> he answers in a professional tone."
;

+ AskTopic, AskTopicAboutWater @well;

// ****************** Restrooms *********************
fortRestrooms : OutdoorRoom 'In the restrooms'
  "This section of the fort is isolated from the yard by a wooden planking.
  A series of curtained stalls containing a mere hole in the ground provide simple commodities
  to the inhabitants. In front of the stalls is a small podium with a head-box pillory on it.
  \^<<pillory.pilloryPrisoner ? '' : 'It is currently empty. '>>

  <<well.isWorking ? 'A regular, loud thump thump thump is coming from the north west'
    : ''>>. "

  west = fortYard

  roomParts = [fortWall]
  isPrivate = true
;

+ Distant 'pumping well/pump/machine' 'pump'
  "The well lies to the north of the fort yard, which is to your west. "
;

+ pillory : Fixture, NominalPlatform 'wooden pillory/podium' 'pillory'
  "This is a one-metre-wide, square podium holding a one-metre-high post on one of its sides.
  The post is holding a cubic wooden box.
  A shackle is set on both side of the box to hold the prisoner's wrists.
  On the opposite side of the podium is a set of stocks
  designed to keep the prisoner's feet wide apart.
  '\^' + <<pilloryPrisoner.aName + ' is currently locked in. '>>"
  actorInPrep = 'on'
  pilloryPrisoner = katTheRed
;

+ pilloryBox : Openable, Fixture 'wooden head pillory box/head-box' 'pillory box'
  "The box is at the top end of the pillory post, about one metre above the podium.
  It has two holes in it: one to hold the prisoner's neck, and the other linked to a ring-gag,
  providing easy access to the prisoner's mouth. "

  openStatus = (isOpen && pillory.pilloryPrisoner
    ? '\^' + pillory.pilloryPrisoner.theName + '\'s sweaty face is looking at you from the open box with pleading eyes. '
    : 'The prisoner\' head is totally concealed inside it. ')

  dobjFor(Open)
  {
    action()
    {
      if(pillory.pilloryPrisoner == katTheRed && (!katTheRed.isProperName))
      {
        katTheRed.makeProper;
        okayOpenMsg = 'You open the head box and unstrap the ring gag from the prisoner\'s mouth. ';
      }else
      {
        okayOpenMsg = 'You open the head box and unstrap the ring gag from the prisoner\'s mouth. ';
      }

      inherited();
    }
  }
  dobjFor(Close)
  {
    action()
    {
      if(pillory.pilloryPrisoner)
      {
        okayOpenMsg = 'You force the ring gag into '+pillory.pilloryPrisoner.theName+'\'s mouth and
          close the box. ';
      }else
      {
        okayOpenMsg = 'You close the head box. ';
      }

      inherited();
    }
  }
;

+ pilloryShackles : Fixture, Openable 'wrist shackles/shackle' 'shackles'
  "Those are thick, iron shackles fixed to the sides of the head box,
  designed to hold the prisoner's hands.
  << isOpen ? 'They are currently open. ' : pillory.pilloryPrisoner.theName + '\'s wrists are locked in them. '>> "
  isOpen = nil
;

+pilloryStocks : Fixture, Openable 'wooden ankle stocks/stockade' 'stocks'
  "This is a heavy piece of timber, longitudinally sawed in two and hinged at one end.
  Two holes have been cut out so as to keep the prisoner's ankles one-metre wide apart.
  << isOpen ? 'They are currently open. ' : pillory.pilloryPrisoner.theName + '\'s ankles are currently locked in. '>> "
  isOpen = nil
;
